/**
 * com.cnhis.his.customer.service.Bdt1Service.java
 */
package com.mbmed.doctor.medadvice.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.commons.mapper.ModelVo;
import com.mbmed.doctor.medadvice.bo.Bdt1Bo;
import com.mbmed.doctor.medadvice.mapper.Bdt1;

/**
 * @file  Bdt1Service.java
 * @author 刘武
 * @version 0.1
 * @todo	Bdt1服务操作接口
 * Copyright(C), 2013-2014
 *		 Shenzhen Coordinates Software Development Co., Ltd.
 * History
 *   	1. Date: 2014-12-15 06:46:06
 *      	Author: 刘武
 *      	Modification: this file was created
 *   	2. ...
 */
@Path("/bdt1")
@Component
public class Bdt1Service {
	
	private static Logger logger = Logger.getLogger(Bdt1.class);
	
	@Autowired
	private Bdt1Bo bdt1Bo;
	
	@Context
	Request request;

	
	/**
	 * 查找所有数据库记录
     * @return type : List 返回查询操作所有符合条件的记录的VO对象集合，操作失败返回null
     */
	@GET
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public List<Bdt1> getAll() throws Exception{
        List<Bdt1> list = new ArrayList<Bdt1>();
        return bdt1Bo.getAll();        
    }
	
    /**
     * 查找符合条件的所有数据库记录
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("{id}")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public Bdt1 getBdt1(@PathParam("id") String id) throws Exception{
    	Bdt1 bdt1 = null;
    	return bdt1Bo.get(id);        
    }
	
	
	/**
     * 皮试药物对应皮试项目
     * @param id 与数据库中主键对应的值
     * @return type :  药品：门诊按规格下医嘱，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("/getbdt1bybbx01")
	@Produces({MediaType.APPLICATION_JSON})
    public ModelVo  getBdt1ByBbx01(
    		@QueryParam("bbx01a") java.lang.String bbx01a,
    		@QueryParam("bdt03") java.lang.String bdt03
    		) throws Exception{
		ModelVo modelVo = new ModelVo();

		
		List<Bdt1> list = new ArrayList<Bdt1>();
		Map<String,Object> paramap = new HashMap<String,Object>();
		paramap.put("bbx01a", Integer.parseInt(bbx01a));
		paramap.put("bdt03", Integer.parseInt(bdt03));
		list = bdt1Bo.getBdt1ByBbx01(paramap);
		modelVo.setList(list);
    	return modelVo;
	}
	
	
	
	
    /**
     * 向数据库中插入一条记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : 返回插入操作是否成功
     * @throws Exception
     */
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	public Bdt1 saveBdt1(
			@FormParam("bdt01") java.lang.Integer bdt01,
			@FormParam("bbx01a") java.lang.Integer bbx01a,
			@FormParam("bdt03") java.lang.Integer bdt03,
			@FormParam("bbx01b") java.lang.Integer bbx01b,
			@FormParam("bdi01") java.lang.String bdi01,
			@FormParam("bdt06") java.math.BigDecimal bdt06,
			@FormParam("bdt07") java.math.BigDecimal bdt07,
			@FormParam("bdt08") java.lang.String bdt08,
			@FormParam("bdt09") java.lang.Integer bdt09,
			@FormParam("bdt10") java.math.BigDecimal bdt10,
			@Context HttpServletResponse servletResponse
	) throws Exception {
		Bdt1 bdt1 = new Bdt1();
		bdt1.setBdt01(bdt01);
		bdt1.setBbx01a(bbx01a);
		bdt1.setBdt03(bdt03);
		bdt1.setBbx01b(bbx01b);
		bdt1.setBdi01(bdi01);
		bdt1.setBdt06(bdt06);
		bdt1.setBdt07(bdt07);
		bdt1.setBdt08(bdt08);
		bdt1.setBdt09(bdt09);
		bdt1.setBdt10(bdt10);

		return bdt1 = bdt1Bo.save(bdt1);

	}
	/**
     * 删除数据库中与传入的值对象对应的记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : boolean 返回删除操作是否成功
     * @throws Exception
     */
	@DELETE
	@Path("{id}")
	public boolean removeBdt1(@PathParam("id") String id) throws Exception{
		if(id == null) return false;
    	return bdt1Bo.remove(id);

	}
	
}
